﻿using Microsoft.Practices.Unity;
using SocialCee.ExternalSystems.Common;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SocialCee.Framework
{
    /// <summary>
    /// Container for social media client portals
    /// </summary>
    public class Container
    {
        /// <summary>
        /// Register clients
        /// </summary>
        /// <param name="SocialMediaClients"></param>
        public void RegisterClients(IExternalSystemsFactory SocialMediaClients)
        {
            UnityContainer unityContainer = new UnityContainer();

            if (SocialMediaClients != null)
            {
                unityContainer.RegisterInstance<List<string>>("SocialMediaClientsNames", SocialMediaClients.GetClientNames());
                unityContainer.RegisterInstance<Dictionary<string, IClient>>("SocialMediaClients", SocialMediaClients.GetClients());
                //Logger
                //container.RegisterType<UpdateManager>(new InjectionConstructor(updatesFolderFullName));
                unityContainer.RegisterInstance<UnityContainer>(unityContainer);
            }

            UnityServiceLocator locator = new UnityServiceLocator(unityContainer);
            Microsoft.Practices.ServiceLocation.ServiceLocator.SetLocatorProvider(() => locator);
        }
    }
}
